using FluentValidation;
using Jupiter.Infrastructure.Domain;
using MediatR;

namespace Wips.AppService.Authorities.Positions.Requests
{
    /// <summary>
    /// 给职位分配角色请求类
    /// </summary>
    public class AssignRolesForPositionRequest : IRequest<string>,ITxRequest
    {
        /// <summary>
        /// 职位Id
        /// </summary>
        public string PositionId { get; set; }

        /// <summary>
        /// 角色Id列表
        /// </summary>
        public IList<string> RoleIds { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    public class AssignRolesForPositionValidator : AbstractValidator<AssignRolesForPositionRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public AssignRolesForPositionValidator()
        {
            RuleFor(p => p.RoleIds)
                .Must(list => list.Count > 0)
                .WithMessage("未选择角色");

            RuleFor(p => p.PositionId)
                .Must(id => !string.IsNullOrEmpty(id))
                .WithMessage("职位不能为空");
        }
    }
}